{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 这里是Markdown单元格"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World, Hello PyTorch 1.10.1+cu102\n",
      "\n",
      "CUDA is available:True, version is 10.2\n",
      "\n",
      "device_name: NVIDIA GeForce GTX 1660 Ti with Max-Q Design\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "\n",
    "print(\"Hello World, Hello PyTorch {}\".format(torch.__version__))\n",
    "\n",
    "print(\"\\nCUDA is available:{}, version is {}\".format(torch.cuda.is_available(), torch.version.cuda))\n",
    "\n",
    "print(\"\\ndevice_name: {}\".format(torch.cuda.get_device_name(0)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 连个神奇操作\n",
    "! 以及 %% 使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wed Dec 22 22:01:48 2021       \n",
      "+-----------------------------------------------------------------------------+\n",
      "| NVIDIA-SMI 471.41       Driver Version: 471.41       CUDA Version: 11.4     |\n",
      "|-------------------------------+----------------------+----------------------+\n",
      "| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |\n",
      "| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n",
      "|                               |                      |               MIG M. |\n",
      "|===============================+======================+======================|\n",
      "|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0 Off |                  N/A |\n",
      "| N/A    0C    P8     8W /  N/A |    153MiB /  6144MiB |      0%      Default |\n",
      "|                               |                      |                  N/A |\n",
      "+-------------------------------+----------------------+----------------------+\n",
      "                                                                               \n",
      "+-----------------------------------------------------------------------------+\n",
      "| Processes:                                                                  |\n",
      "|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n",
      "|        ID   ID                                                   Usage      |\n",
      "|=============================================================================|\n",
      "|  No running processes found                                                 |\n",
      "+-----------------------------------------------------------------------------+\n",
      "22:01\n",
      " 驱动器 E 中的卷是 文档 \n",
      " 卷的序列号是 50F5-50B5\n",
      "\n",
      " E:\\pytorch-tutorial-2nd\\code\\chapter-1 的目录\n",
      "\n",
      "2021/12/22/周三  16:09    <DIR>          .\n",
      "2021/12/22/周三  16:09    <DIR>          ..\n",
      "2021/12/22/周三  11:59    <DIR>          .ipynb_checkpoints\n",
      "2021/12/22/周三  10:42               419 01-hello-pytorch.py\n",
      "2021/12/22/周三  16:09             4,146 02-notebook-demo.ipynb\n",
      "               2 个文件          4,565 字节\n",
      "               3 个目录 31,267,934,208 可用字节\n"
     ]
    }
   ],
   "source": [
    "!nvidia-smi\n",
    "!time /t\n",
    "!dir"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "858 ns ± 50.3 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "a = []\n",
    "for i in range(10):\n",
    "    a.append(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wall time: 127 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "a = []\n",
    "for i in range(1000000):\n",
    "    a.append(i)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pytorch_1.10_gpu",
   "language": "python",
   "name": "pytorch_1.10_gpu"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.13"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
